package o;

import android.content.Context;
import android.text.TextUtils;
import android.util.SparseArray;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.hmf.annotation.ApiDefine;
import com.huawei.hmf.annotation.Singleton;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import o.brg.e;

@ApiDefine(uri = brg.class)
@Singleton
public final class brt implements brg {
    private static final SparseArray<e> ˊ = new SparseArray();
    private static final SparseArray<e> ˋ = new SparseArray();
    private static c ˏ = new c();
    private static b ॱ = new b();

    static class b implements o.cii.c {
        private b() {
        }

        public void ˏ(Context context, BaseCardBean baseCardBean) {
            brt.ˊ(context, baseCardBean, true);
        }
    }

    static class c implements o.cii.c {
        private c() {
        }

        public void ˏ(Context context, BaseCardBean baseCardBean) {
            brt.ˊ(context, baseCardBean, false);
        }
    }

    private static void ˊ(Context context, BaseCardBean baseCardBean, boolean z) {
        if (baseCardBean != null && !TextUtils.isEmpty(baseCardBean.ॱॱ())) {
            String ॱॱ = baseCardBean.ॱॱ();
            if (!TextUtils.isEmpty(ॱॱ)) {
                String substring;
                e eVar;
                int indexOf = ॱॱ.indexOf(124);
                if (indexOf != -1) {
                    ॱॱ = ॱॱ.substring(indexOf + 1);
                    indexOf = ॱॱ.indexOf(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
                    if (indexOf != -1) {
                        substring = ॱॱ.substring(0, indexOf);
                        if (z) {
                            eVar = (e) ˋ.get(substring.hashCode());
                        } else {
                            eVar = (e) ˊ.get(substring.hashCode());
                        }
                        if (eVar == null) {
                            eVar.ˎ(context, baseCardBean);
                        } else {
                            bqx.ˊ("ForumCardEventDispatcher", "listener is null: " + substring);
                        }
                    }
                }
                substring = ॱॱ;
                if (z) {
                    eVar = (e) ˋ.get(substring.hashCode());
                } else {
                    eVar = (e) ˊ.get(substring.hashCode());
                }
                if (eVar == null) {
                    bqx.ˊ("ForumCardEventDispatcher", "listener is null: " + substring);
                } else {
                    eVar.ˎ(context, baseCardBean);
                }
            }
        }
    }

    public static void ॱ() {
        cii.ॱ("forum", ˏ);
        cii.ॱ("buoy_forum", ॱ);
    }

    public void ˊ(String str, e eVar) {
        if (!TextUtils.isEmpty(str) && eVar != null) {
            ˋ.put(str.hashCode(), eVar);
        }
    }

    public void ˏ(String str, e eVar) {
        if (!TextUtils.isEmpty(str) && eVar != null) {
            ˊ.put(str.hashCode(), eVar);
        }
    }

    public void ˏ(Context context, String str) {
        BaseCardBean baseCardBean = new BaseCardBean();
        baseCardBean.ॱ(str);
        cii.ˊ().ˊ(context, baseCardBean, 0);
    }
}
